package com.ruoyi.system.controller;

import java.util.List;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WmsOutbound;
import com.ruoyi.system.service.IWmsOutboundService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出库信息Controller
 *
 * @author ruoyi
 * @date 2025-06-24
 */
@RestController
@RequestMapping("/system/wmsOutbound")
public class WmsOutboundController extends BaseController
{
    @Autowired
    private IWmsOutboundService wmsOutboundService;

    /**
     * 查询出库信息列表
     */
    @SaCheckPermission("system:wmsOutbound:list")
    @GetMapping("/list")
    public TableDataInfo<WmsOutbound> list(WmsOutbound wmsOutbound, PageQuery pageQuery)
    {
        return wmsOutboundService.selectWmsOutboundList(wmsOutbound, pageQuery);
    }

    /**
     * 导出出库信息列表
     */
    /*@SaCheckPermission("system:wmsOutbound:export")
    @Log(title = "出库信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsOutbound wmsOutbound)
    {
        List<WmsOutbound> list = wmsOutboundService.selectWmsOutboundList(wmsOutbound);
        ExcelUtil<WmsOutbound> util = new ExcelUtil<WmsOutbound>(WmsOutbound.class);
        util.exportExcel(response, list, "出库信息数据");
    }*/

    /**
     * 获取出库信息详细信息
     */
    @SaCheckPermission("system:wmsOutbound:query")
    @GetMapping(value = "/{id}")
    public R<WmsOutbound> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(wmsOutboundService.selectWmsOutboundById(id));
    }

    /**
     * 新增出库信息
     */
    @SaCheckPermission("system:wmsOutbound:add")
    @Log(title = "出库信息", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Void> add(@RequestBody WmsOutbound wmsOutbound)
    {
        return toAjax(wmsOutboundService.insertWmsOutbound(wmsOutbound));
    }

    /**
     * 修改出库信息
     */
    @SaCheckPermission("system:wmsOutbound:edit")
    @Log(title = "出库信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Void> edit(@RequestBody WmsOutbound wmsOutbound)
    {
        return toAjax(wmsOutboundService.updateWmsOutbound(wmsOutbound));
    }

    /**
     * 删除出库信息
     */
    @SaCheckPermission("system:wmsOutbound:remove")
    @Log(title = "出库信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R<Void> remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsOutboundService.deleteWmsOutboundByIds(ids));
    }

    /**
     * 获取出库单号
     */
    @SaCheckPermission("system:wmsOutbound:query")
    @GetMapping(value = "/getOutboundOrderNo")
    public R<WmsOutbound> getOutboundOrderNo()
    {
        return R.ok(wmsOutboundService.getOutboundOrderNo());
    }
    /**
     * 取消出库单号
     */
    @SaCheckPermission("system:wmsOutbound:query")
    @GetMapping(value = "/clearOrderNo")
    public R<Void> clearOrderNo()
    {
        wmsOutboundService.clearOrderNo();
        return R.ok("ok");
    }



    /**
     * 查询入库商品信息列表
     */
    @SaCheckPermission("system:wmsOutbound:list")
    @GetMapping("/getInboundProducts")
    public TableDataInfo<WmsOutbound> getInboundProducts(WmsOutbound wmsOutbound, PageQuery pageQuery)
    {
        return wmsOutboundService.getInboundProducts(wmsOutbound,pageQuery);
    }

    @SaCheckPermission("system:wmsOutbound:list")
    @GetMapping("/getInboundProductsByPage")
    public TableDataInfo<WmsOutbound> getInboundProductsByPage(WmsOutbound wmsOutbound, PageQuery pageQuery)
    {
        return wmsOutboundService.getInboundProductsByPage(wmsOutbound,pageQuery);
    }

    /**
     * 查询入库商品信息列表不需要分页
     */
    @SaCheckPermission("system:wmsOutbound:list")
    @PostMapping("/getInboundProductsByWmsInventoryCheckEdit")
    public R<List<WmsOutbound>> getInboundProductsByWmsInventoryCheckEdit(@RequestBody WmsOutbound wmsOutbound)
    {
        return R.ok(wmsOutboundService.getInboundProductsByWmsInventoryCheckEdit(wmsOutbound));
    }
    /**
     * 查询入库商品信息列表不需要分页
     */
    @SaCheckPermission("system:wmsOutbound:list")
    @GetMapping("/getInboundProductsByWmsInventoryCheckAdd")
    public R<List<WmsOutbound>> getInboundProductsByWmsInventoryCheckAdd(WmsOutbound wmsOutbound)
    {
        return R.ok(wmsOutboundService.getInboundProductsByWmsInventoryCheckAdd(wmsOutbound));
    }

    /**
     * 作废
     */
    @SaCheckPermission("system:wmsOutbound:edit")
    @Log(title = "出库信息", businessType = BusinessType.UPDATE)
    @PutMapping("/cancellation")
    public R<Void> cancellation(@RequestParam Long id)
    {
        return toAjax(wmsOutboundService.cancellation(id));
    }
}
